app.controller('GetRolesCtrl',function ($scope,$http,$location,$window,$state,$localStorage) {
	$scope.namedata = $localStorage.cur_user.uname;
	$scope.getrolelist = function(pa){
		$scope.currentPage = 1;//初始当前页
	    $scope.maxSize = 3;//最多显示3页其他的用···代替
		$http.post(
	        $scope.app.backendurl+"admin-role/view-all",
	        {  
	        	'page': $scope.currentPage,       
	            'token':$localStorage.token                  

	        }
	    ).success(function (data) {
	       //console.log(data);
	      if(data.code==0&&data.msg==""){
	      	$scope.aaData = data.data.list;
	      	$scope.totalItems = data.data.pages.totalCount;
	      	setPage(pa);
	      }
	      if(data.code==20001&&data.msg=="请先登录"){
	      	$location.path('access.signin');
	      }
	      
	     
	      $scope.pageChanged = function(){
	      	//console.log($scope.currentPage);
	      	$http.post(
		        $scope.app.backendurl+"admin-role/view-all",
		        {
		        	'page': $scope.currentPage,   
		            'token':$localStorage.token                  

		        }
		    ).success(function (data) {
		    	
		    	if(data.code==0&&data.msg==''){
			      	$scope.aaData = data.data.list;		      	
			    }
			    if(data.code==20001&&data.msg=="请先登录"){
			      	$location.path('access.signin');
			    }

		     }).error(function (data) {
			       alert(data);
			 })
	      }
	      
	    
	    }).error(function (data) {
	        alert(data);
	    })
	}
	//console.log($state.params.page);
	$scope.getrolelist($state.params.page);
	


    function setPage (pageNo) {
		$scope.currentPage = pageNo || '1';
		$http.post(
		        $scope.app.backendurl+"admin-role/view-all",
		        {
		        	'page': $scope.currentPage,   
		            'token':$localStorage.token                  

		        }
		    ).success(function (data) {

		    	if(data.code==0&&data.msg==''){
			      	$scope.aaData = data.data.list;		      	
			    }
			    if(data.code==20001&&data.msg=="请先登录"){
			      	$location.path('access.signin');
			    }

		     }).error(function (data) {
			       alert(data);
			 })	    
		
		
	}

	
})